package com.mz.ozy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import com.mz.ozy.R;
import com.mz.ozy.bean.JDDetailBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 *
 */

public class JdDetailAdapter extends RecyclerView.Adapter<JdDetailAdapter.MyViewHolder> {


    private Context mContext;
    List<JDDetailBean.PageBean.PageItemsBean> mBeanList;

    public JdDetailAdapter(Context context, List<JDDetailBean.PageBean.PageItemsBean> mBeanList) {
        mContext = context;
        this.mBeanList = mBeanList;

    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_balance_detail, parent, false));
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        JDDetailBean.PageBean.PageItemsBean bean = mBeanList.get(position);
        int sztype = bean.getSztype();
        if (sztype == 0) {
            holder.tvMoney.setTextColor(mContext.getResources().getColor(R.color.c_f63148));
            holder.tvMoney.setText("+" + bean.getAmount());
        } else if (sztype == 1) {
            holder.tvMoney.setTextColor(mContext.getResources().getColor(R.color.text_color_333333));
            holder.tvMoney.setText("-" + bean.getAmount());
        }
        holder.tvDate.setText(bean.getCreated());
        int lxtype = bean.getLxtype();
        switch (lxtype) {
            case 0:
                holder.tvRemark.setText(R.string.jd_detail_type0);
                break;
            case 1:
                holder.tvRemark.setText(R.string.jd_detail_type1);

                break;
            case 2:
                holder.tvRemark.setText(R.string.jd_detail_type2);

                break;
            case 3:
                holder.tvRemark.setText(R.string.jd_detail_type3);

                break;
            case 4:
                holder.tvRemark.setText(R.string.jd_detail_type4);

                break;
            case 5:
                holder.tvRemark.setText(R.string.jd_detail_type5);

                break;
            case 6:
                holder.tvRemark.setText(R.string.jd_detail_type6);

                break;
            case 7:
                holder.tvRemark.setText(R.string.jd_detail_type7);

                break;
            case 8:
                holder.tvRemark.setText(R.string.jd_detail_type8);

                break;
            case 9:
                holder.tvRemark.setText(R.string.jd_detail_type9);

                break;
            case 10:
                holder.tvRemark.setText(R.string.jd_detail_type10);

                break;

        }

    }

    @Override
    public int getItemCount() {
        return mBeanList.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_remark)
        TextView tvRemark;
        @BindView(R.id.tv_date)
        TextView tvDate;
        @BindView(R.id.tv_money)
        TextView tvMoney;
        @BindView(R.id.ll_item)
        LinearLayout llItem;

        public MyViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }


    }


}
